package com.supermap.localization.commontypes;

import java.util.ArrayList;
import java.util.List;

public class SampleInfo {

    private String key;

    private String value;

    private String translate;

    private List<LocationInfo> location;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public List<LocationInfo> getLocation() {
        if (location == null) {
            location = new ArrayList<>();
        }
        return location;
    }

    public void setLocation(List<LocationInfo> location) {
        this.location = location;
    }

    public String getTranslate() {
        return translate;
    }

    public void setTranslate(String translate) {
        this.translate = translate;
    }

    public void addLocation(String fileName, int lineNum) {
        LocationInfo info = new LocationInfo();
        info.setFileName(fileName);
        info.setLineNum(lineNum);
        addLocation(info);
    }

    public void addLocation(LocationInfo info) {
        if (location == null) {
            location = new ArrayList<>();
        }
        location.add(info);
    }

    public String format() {
        return key + "=" + value;
    }

    public String formatTranslate() {
        return key + "=" + translate;
    }

    public String formatLocation() {
        StringBuilder sb = new StringBuilder();
        sb.append(key + " -------- ");
        for (int i = 0; i < location.size(); i++) {
            LocationInfo currentLocation = location.get(i);
            sb.append(currentLocation.getFileName() + " , " + currentLocation.getLineNum() + "; ");
        }
        return sb.toString();
    }

}
